package net.roobook.cms.common.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author cos
 * @email 327878610@qq.com
 * @link https://roobook.net
 * @Description RequestUtils
 * @date 2023/9/26 10:16
 **/
public class RequestEntity {
    //远程地址
    public String remoteAddr;
    //浏览器型号
    public String broswer;
    //平台型号
    public String platform;

    public String getRemoteAddr() {
        return remoteAddr;
    }

    public void setRemoteAddr(String remoteAddr) {
        this.remoteAddr = remoteAddr;
    }

    public String getBroswer() {
        return broswer;
    }

    public void setBroswer(String broswer) {
        this.broswer = broswer;
    }

    public String getPlatform() {
        return platform;
    }

    public void setPlatform(String platform) {
        this.platform = platform;
    }

    public RequestEntity(){

    }

    public RequestEntity(String remoteAddr, String broswer, String platform) {
        this.remoteAddr = remoteAddr;
        this.broswer = broswer;
        this.platform = platform;
    }

    /**
     * 获得HandlerRequest
     * @param request
     * @return
     */
    public static RequestEntity fromWebRequest(HttpServletRequest req){
        RequestEntity request = new RequestEntity();
        request.setRemoteAddr(HttpRequestUtil.getRequestAddr(req));
        request.setBroswer(HttpRequestUtil.getBrowser(req));
        request.setPlatform(HttpRequestUtil.getPlatform(req));
        return request;
    }
}
